import request from "@/utils/request";
import { TagForm, TagQuery, TagVo } from "@/api/tag/type";

const api: string = "/tags";

/** 查询标签列表数据 */
export function getTagOptions(): Result<SelectBox[]> {
  return request({
    url: `${api}/options`,
    method: "get",
  });
}

/** 分页查询标签 */
export function getTagPageApi(params: TagQuery): Result<TagVo> {
  return request({
    url: `${api}/page`,
    method: "get",
    params,
  });
}

/** 获取标签展示form信息 */
export function getTagFormApi(id: number): Result<TagForm> {
  return request({
    url: `${api}/${id}/form`,
    method: "get",
  });
}

/** 添加标签 */
export function addTagApi(data: TagForm): Result<void> {
  return request({
    url: `${api}`,
    method: "post",
    data,
  });
}

/** 更新标签 */
export function updateTagApi(data: TagForm): Result<void> {
  return request({
    url: `${api}`,
    method: "put",
    data,
  });
}

/** 删除标签 */
export function deleteTagsApi(ids: string) {
  return request({
    url: `${api}/${ids}`,
    method: "delete",
  });
}
